home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6964 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: hacgate2.hac.com!redwood!ddavenpo
  2. From: ddavenpo@redwood.hac.com (Darren C Davenport)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. Followup-To: comp.lang.ada,comp.lang.c++
  6. Date: 21 Feb 1996 00:12:26 GMT
  7. Organization: Hughes Aircraft Company
  8. Message-ID: <4gdo1a$8ds@hacgate2.hac.com>
  9. References: <4gbq7q$g08@qualcomm.com>
  10. NNTP-Posting-Host: redwood.dn.hac.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Nasser Abbasi (nabbasi@qualcomm.com) wrote:
  14.  
  15.  
  16. : Hello,
  17.  
  18. : I have a simple comment, but probably a long way of 
  19. : showing it :)
  20.  
  21. : I have been playing around with the OO features in Ada95 and
  22. : comparing it with C++. I noticed this little difference, and I'd
  23. : like to see what you think of it.
  24.  
  25. : Lets assume we have a base class called Account, and a class called
  26. : Saving_Account that uses Account as base. 
  27.  
  28. : Lets also assume that we need to define a Money Type, defined in
  29. : the base class Account.     
  30.  
  31. : In Ada95 this type is defined in the package Account.ads that also
  32. : includes the definition of the tagged record type Account (along with
  33. : operations that act on Account type).
  34.  
  35. : In C++, this Money Type is typedef'ed inside the public part of the
  36. : class Account, and it becomes part of the public interface of the
  37. : base class.
  38.  
  39. : so far so good.
  40.  
  41. : Now, In Ada95, a client that wishes to use Saving_Account type (and
  42. : any operations on it) will "with" the Saving_Account Package.
  43.  
  44. : Also, in C++, a client who wishes to use Saving_Account class will
  45. : include "saving_account.h"
  46.  
  47. : There is some differences though.
  48.  
  49. : In C++, the client to the saving_account class can also use the
  50. : Money_Type type (even though that is defined in
  51. : the base class Account) without having to include base class
  52. : "account.h", this is because Money_Type has become a public part of the
  53. : Saving_Account class when Saving_Account inherited Saving class.
  54.  
  55. : In Ada95, the client of Saving_Account has no viability to Money_Type
  56. : type definition even though they with'ed Saving_account package, since
  57. : Money_Type is not a "inherited" by the Saving_Account package
  58. : from the Account package. This means that in Ada95, If one wants to
  59. : access things like type definitions that are not tagged, but 
  60. : used in defining components inside the tagged record, one must
  61. : "with" the client package and also packages that the client package
  62. : with'ed just to be able to have viability to those type definitions.
  63.  
  64. The other option is to to put Saving_Account_Type into to a child
  65. package of account, say account.savings.  Then when you with account.savings
  66. you get the anything the parent package has that's visible.
  67.  
  68. Darren
  69.  
  70.